#include "MavenResult.h"
#include <QJsonDocument>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonArray>

MavenResult::MavenResult(QObject *parent) : QObject(parent)
, id("")
, g("")
, a("")
, latestVersion("")
, repositoryId("")
, p("")
, timestamp(0)
, versionCount(0)
, text("")
, ec("")
{
    
}

void MavenResult::setValue(const QJsonObject &doc){
    if (doc.isEmpty()) return;
    id             = doc.value("id").toString();
    g              = doc.value("g").toString();
    a              = doc.value("a").toString();
    latestVersion  = doc.value("latestVersion").toString();
    repositoryId   = doc.value("repositoryId").toString();
    p              = doc.value("p").toString();
    timestamp      = doc.value("timestamp").toInt();
    versionCount   = doc.value("versionCount").toInt();
    if (!doc.contains("latestVersion"))
        latestVersion  = doc.value("v").toString();

    // text           = doc.value("text").toString();
    // ec             = doc.value("ec").toString();
}